#include<bits/stdc++.h>
using namespace std;
int T,d[100005],v[100005],a[100005],p[1000005];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        int n,m,L,V,s=0,xx=1;
        cin>>n>>m>>L>>V;
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v[i]>V){
                    int l=1,r=n+1,ll=0,rr=m,mid=0;
                    while(l<r){
                        mid=(l+r)/2;
                        if(p[mid]==d[i]){
                            ll=mid;
                            break;
                        }
                        if(p[mid]<d[i])l=mid+1;
                        else r=mid;
                    }
                    if(ll==0)ll=mid;
                    if(p[ll]>=d[i]){
                        s++;
                    }
                }
            }
            else if(a[i]>0){
                if(v[i]>V){
                    int l=1,r=n+1,ll=0,rr=m,mid=0;
                    while(l<r){
                        mid=(l+r)/2;
                        if(p[mid]==d[i]){
                            ll=mid;
                            break;
                        }
                        if(p[mid]<d[i])l=mid+1;
                        else r=mid;
                    }
                    if(ll==0)ll=mid;
                    if(p[ll]>=d[i]){
                        s++;
                    }
                }
                else{
                    long long vma=(V*V-2*a[i]*(L-d[i]));
                    vma=sqrt(vma);
                    if(vma<v[i]){
                        long long z=d[i]+(V*V-v[i]*v[i])/(2*a[i]);
                        if((V*V-v[i]*v[i])%(2*a[i])!=0)z++;
                        int l=1,r=n+1,ll=0,rr=m,mid=0;
                        while(l<r){
                            mid=(l+r)/2;
                            if(p[mid]==z){
                                ll=mid;
                                break;
                            }
                            if(p[mid]<z)l=mid+1;
                            else r=mid;
                        }
                        if(ll==0)ll=mid;
                        if(p[ll]>=z){
                            s++;
                        }
                    }
                }
            }
            else{
                if(v[i]>V){
                    long long z=d[i]+(V*V-v[i]*v[i])/(2*a[i]);
                    if((V*V-v[i]*v[i])%(2*a[i])!=0)z++;
                    if(z<=L){
                        int l=1,r=n+1,ll=0,rr=0,mid=0;
                        while(l<r){
                            mid=(l+r)/2;
                            if(p[mid]==d[i]){
                                ll=mid;
                                break;
                            }
                            if(p[mid]<d[i])l=mid+1;
                            else r=mid;
                        }
                        if(ll==0)ll=mid;
                        l=0;r=n;mid=0;
                        while(l<r){
                            mid=(l+r)/2;
                            if(p[mid]==z){
                                rr=mid;
                                break;
                            }
                            if(p[mid]<z)l=mid;
                            else r=mid-1;
                        }
                        if(rr==0)rr=mid-1;
                        if(ll<=rr){
                            s++;
                        }
                    }
                }
            }

        }
        cout<<s<<" ";
        xx--;
        cout<<m-1;

    }

    return 0;
}
